{include file="public/header"}
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>分享分步骤任务发布</title>
    <link rel="stylesheet" type="text/css" href="__CSS__/tt.css"/>
    <!--<link rel="stylesheet" href="__JS__/webuploader/webuploader.css" >&lt;!&ndash;webUploader上传组件&ndash;&gt;-->
    <!--<link rel="stylesheet" href="__JS__/webuploader/style.css" >&lt;!&ndash;webUploader上传组件&ndash;&gt;-->
    <link href="/static/admin/css/font-awesome.min.css?v=4.7.0" rel="stylesheet">
    <link href="__JSS__/plugins/layui/css/layui.css" rel="stylesheet">
    <style type="text/css">

        html body {
            margin: 0;
            background-color: #EEEEEE;
            width: 100%;
            height: 100%;
            font-size: 14px;
            color: #333333;
            font-weight: 500;
        }

        .flex-wrap {
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .flex-con {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
        }

        .flex-vertical {
            -webkit-box-horizontal: vertical;
            -webkit-flex-flow: column;
            flex-flow: column;
        }

        .wrap1 {
            width: 100%;
            background: #3F3F3F;
            height: 30px;
            line-height: 30px;
        }

        .wrap1 .content1 {
            margin: 0 auto;
            width: 1200px;
            font-size: 12px;
            color: #ffffff;
            /*position: relative;*/
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .kong {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
        }

        .content12 {
            position: relative;
        }

        .redhot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #BA0000;
            position: absolute;
            left: 24px;
            top: 5px;
        }

        .wrap2 {
            line-height: 60px;
            width: 100%;
            height: 60px;
            background: #ffffff;
        }

        .content2 {
            margin: auto;
            width: 1200px;
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .content2_left {
            width: 190px;
            font-size: 18px;
            color: #333333;
        }

        .content2_left span {
            display: inline-block;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: #0065F0;
            vertical-align: middle;
            margin-right: 11px;
        }

        .content_middle {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            text-align: left;
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;

        }

        .content_right {
            font-size: 16px;
        }

        .content_right img {
            display: inline-block;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            margin-right: 20px;
            vertical-align: middle;
        }

        .content_middle .item {
            width: 152px;
        }

        .content_middle .item.active2 {
            color: #0065F0;
        }

        .wrap3 {
            line-height: 60px;
            width: 100%;
            height: 60px;
            background: #0065F0;
        }

        .content3 {
            margin: auto;
            width: 1200px;
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .content3-left {
            line-height: 60px;
            color: #ffffff;
            font-size: 16px;
        }

        .wrap4 {
            background: #EEEEEE;
            width: 100%;
            padding-top: 30px;
            padding-bottom: 80px;

        }

        .content4 {
            margin: auto;
            width: 1200px;
            /*display: flex;*/
            background: #ffffff;
            padding-top: 50px;
            /*padding-bottom: 40px;*/
        }

        .item4 {
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            margin-bottom: 30px;
        }

        .item4_left {
            width: 184px;
            text-align: right;
            margin-right: 30px;
        }
        .erqifen .item4_left {
            width: 120px;
        }
        .erqifen .item4 {
            margin-bottom: 10px;
        }

        .item4_middle {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            position: relative;
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        select {
            margin-right: 20px;
            /*flex:1;*/
            width: 160px;
            outline: none;
        }

        option {
            width: 160px;
            height: 34px;
        }

        .inputrenwu {
            padding-left: 11px;
            box-sizing: border-box;
            display: inline-block !important;
            width: 520px;
            height: 34px !important;
            line-height: 34px !important;
            border: 1px solid #CCCCCC !important;
            border-radius: 3px;
            outline: none;
        }

        .item4_middle .upload {
            width: 72px;
            height: 34px;
            padding-left: 40px;
            line-height: 34px;
            border: 1px solid #CCCCCC;
            border-radius: 3px;
            margin-right: 60px;
            color: #CCCCCC;
            position: relative;
        }

        .shangchuan {
            position: absolute;
            left: 15px;
            top: 9px;
            width: 16px;
            height: 16px;
            display: block;
        }

        .item4_middle .upload2 {
            width: 82px;
            height: 34px;
            background: #0065F0;
            line-height: 34px;
            border-radius: 3px;
            padding-right: 15px;
            padding-left: 15px;
            padding-right: 15px:
            margin-right: 60px;
            color: #ffffff;
        }

        .item4_middle .upload img {
            vertical-align: middle;
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-right: 10px;
        }

        .item4_middle .text {
            position: absolute;
            left: 0px;
            top: 42px;
            font-size: 12px;
            color: #CCCCCC;
            line-height: 12px
        }

        .ellipsi1 {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .lable {
            width: 110px;
        }

        .lable .span1,.lable .span11 {
            display: inline-block;
            width: 14px;
            height: 14px;
            vertical-align: middle;
            margin-right: 11px;
            border: 1px solid #D9D9D9;
            border-radius: 50%;
        }

        .lable .span2 {
            display: inline-block;
            width: 14px;
            height: 14px;
            vertical-align: middle;
            margin-right: 11px;
            border: 1px solid #0065F0;
            border-radius: 50%;
            background-size: 100% 100%;
            background: url(__IMG__/yuanhuan1.png) no-repeat center center;
        }

        .radioched,.radioched2 {
            display: inline-block;
            width: 14px;
            height: 14px;
            vertical-align: middle;
            margin-right: 11px;
        }

        .span2 img {
            width: 14px;
            height: 14px;
        }

        .hidden {
            display: none !important;
        }

        .danwei {
            font-size: 14px;
            color: #333333;
            margin-left: 10px;
        }

        .item4_middle .add {
            width: 102px;
            height: 102px;
            margin-right: 60px;
            position: relative;
        }

        .delete {
            position: absolute;
            bottom: 0;
            width: 100%;
            left: 0;
            height: 24px;
            line-height: 24px;
            text-align: center;
            background: rgba(0, 0, 0, 0.3);
            color: #ffffff;
            font-size: 12px;
        }

        .add img {
            width: 100%;
            height: 100%;
        }

        .startime {
            /*width: 160px;*/
            height: 34px;
            border: 1px solid #CCCCCC;
            border-radius: 3px;
            padding: 0 10px;
            box-sizing: border-box;
            margin-right: 10px;
            color: #333333;
            display: flex;
            position: relative;

            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .startime_text {
        }

        .startime_middle {
            flex: 1;
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;

        }

        .jianjie {
            width: 520px;
            /*height: 270px;*/
            height: auto;
            padding: 20px;
            box-sizing: border-box;
            background: rgba(255, 255, 255, 1);
            border-radius: 3px;
            border: 1px solid rgba(204, 204, 204, 1);
        }

        .jianjie img {
            display: block;
            width: 100px;
            height: 100px;
            margin-bottom: 16px;
        }

        .jianjie p {
            font-size: 12px;
            line-height: 18px;
            color: #666666;
        }

        .select {
            margin-right: 20px;
            width: 160px;
            height: 34px;
            border-radius: 3px;
            border: 1px solid #cccccc;
            display: flex;
            padding-left: 10px;
            box-sizing: border-box;
            line-height: 34px;
            color: #666666;
            font-size: 12px;
            position: relative;
        }

        .everyoption {
            text-indent: 10px;
            height: 32px;
            line-height: 32px;
            font-size: 12px;
            color: #999999;
        }

        .everyoption:hover {
            background: #0065F0;
            color: #ffffff;

        }

        .alloption {
            display: none;
            background: #ffffff !important;
            z-index: 999;
            padding-left: 0px;

            box-sizing: border-box;
            position: absolute;
            left: 0;
            top: 36px;
            border: 1px solid #eeeeee;
            height: auto;
            box-shadow: 0px 0px 6px 0px rgba(0, 101, 240, 0.6);
            width: 160px;
            overflow-y: scroll;
            max-height: 256px;
        }

        .select .option {
            flex: 1;
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;

        }

        .sanjiao_wrap {
            border-left: 1px solid #cccccc;

            width: 32px;
            height: 32px;
            position: absolute;
            right: 0px;
            top: 0px;
        }

        .sanjiao2 {

            display: block;
            position: absolute;
            left: 50%;
            top: 50%;
            width: 32px;
            height: 32px;
            transform: translate(-50%, -50%);

            -ms-transform: translate(-50%, -50%);
            -moz-transform: translate(-50%, -50%);
            -webkit-transform: translate(-50%, -50%);
            -o-transform: translate(-50%, -50%);
        }

        .sanjiao1 {
            position: absolute;
            left: 50%;
            top: 50%;
            width: 32px;
            height: 32px;
            transform: translate(-50%, -50%) rotate(180deg);

            -ms-transform: translate(-50%, -50%) rotate(180deg);
            -moz-transform: translate(-50%, -50%) rotate(180deg);
            -webkit-transform: translate(-50%, -50%) rotate(180deg);
            -o-transform: translate(-50%, -50%) rotate(180deg);
        }

        * {
            cursor: pointer;
        }

        .btn1 {
            width: 130px;
            height: 34px;
            background: #0065F0;
            color: #ffffff;
            line-height: 34px;
            text-align: center;
            margin-right: 35px;
            font-size: 12px;

        }

        .btn2 {
            font-size: 12px;
            width: 130px;
            height: 34px;
            background: #F7F7F7;
            color: #D9D9D9;
            line-height: 34px;
            text-align: center;
            margin-right: 35px;
        }
    </style>
    <style>
        .selecttttName1 {
            background: #0065F0;
            color: #ffffff;
        }
        .w-e-text-container{
            height: 300px !important;/*!important是重点，因为原div是行内样式设置的高度500px*/
        }
    </style>
</head>

<body>
<div class="wrap3">
    <div class="content3">
        <div class="content3-left">
            任务管理 > 发布
        </div>
    </div>
</div>
<div class="wrap4">
    <!--<form id="fabutask" action="/shop/Task/test" method="post" enctype="multipart/form-data">-->
    <form id="fabutask">
        <div class="content4">
            <div class="item4">
                <div class="item4_left">
                    任务类型
                </div>
                <div class="item4_middle">
                    <div class="select">
                        <div class="option task_type">分享</div>
                    </div>
                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    普通/活动任务
                </div>
                <div class="item4_middle">
                    <div class="select" onclick="selectclick(7);">
                        <div class="option task_active">普通任务</div>
                        <div class="sanjiao_wrap">
                            <img class="sanjiao2" src="__IMG__/select.png" id="sanjiao7">
                        </div>
                    </div>
                    <div class="alloption" id="alloption7">
                        <div class="everyoption" value="1">普通任务</div>
                        <div class="everyoption" value="2">活动任务</div>
                    </div>
                </div>
            </div>
            <div class="item4 task_href">
                <div class="item4_left xiazai">
                    任务链接
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_href" type="text" placeholder="请填写带http的链接地址">
                </div>
            </div>
            <div class="item4 task_share_type">
                <div class="item4_left">
                    分享类型
                </div>
                <div class="item4_middle">
                    <div class="lable">
                        <input type="radio" value="2" checked> 到达率
                    </div>
                </div>

            </div>
            <!--到达率：分步骤 2 -->
            <div class="item4 dao_d">
                <div class="item4_left">
                    是否分步骤
                </div>
                <div class="lable">
                    <input type="radio" name="task_share_d_fen" value="2" checked> 分步骤
                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    每步完成时间
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_share_timeout" id="task_share_timeout" type="text" oninput = "handleMoney(this,0);" placeholder="例如：48" style="width:160px;">
                    <div class="danwei">/小时
                    </div>
                </div>
            </div>
            <!--到达率的二期新增 start-->
            <div style="width: 184px;text-align: right;margin-right: 30px;float: left;">步骤</div>
            <div class="erqifen" style="width:600px;margin:-10px 20px 20px 0;padding-top:20px;border: 1px solid #CCC;float: left;">
                <div class="five" id="five_1">
                    <div class="item4">
                        <div class="item4_left">
                            第 1 步描述
                        </div>
                        <div class="item4_middle">
                            <input class="inputrenwu" maxlength="15" name="tf_desc" type="text" placeholder="步骤简短描述（15个字）" style="width: 300px;">
                            <div onclick="shanchu(this);" class="five_1" style="display:none;margin-left: 100px;margin-top: -15px;border: 1px solid red;padding: 2px;height: 20px;line-height: 20px;border-radius: 2px;color: red;">删除</div>
                        </div>
                    </div>
                    <!--是否需要审核-->
                    <div class="item4">
                        <div class="item4_left">
                            是否上传图
                        </div>
                        <div class="item4_middle">
                            <div class="lable">
                                <input type="radio" name="tf_submit" value="1" checked> <span>是</span>
                            </div>
                            <div class="lable">
                                <input type="radio" name="tf_submit" value="2"> <span>否</span>
                            </div>
                        </div>
                    </div>
                    <!--当前步骤任务金额-->
                    <div class="item4">
                        <div class="item4_left">
                            当前步骤任务金额
                        </div>
                        <div class="item4_middle">
                            <input class="inputrenwu" name="tf_money" type="text" oninput = "handleMoney(this,1);" placeholder="最多保留一位小数" style="width:160px;">
                            <div class="danwei">/平台币

                            </div>
                            <div class="text">注：1元=10平台币
                            </div>


                        </div>
                    </div>
                    <!--分享途径选择 start -->
                    <div class="item4" style="padding-top: 15px;margin-bottom: 20px;">
                        <div class="item4_left">
                            分享渠道
                        </div>
                        <div class="item4_middle">
                            <input type="checkbox" name="tf_qudao[]" value="1" /><label>&nbsp; 微信 &nbsp;&nbsp;&nbsp;</label>
                            <input type="checkbox" name="tf_qudao[]" value="2" /><label>&nbsp; 朋友圈 &nbsp;&nbsp;&nbsp;</label>
                            <input type="checkbox" name="tf_qudao[]" value="3" /><label>&nbsp; QQ &nbsp;&nbsp;&nbsp;</label>
                            <input type="checkbox" name="tf_qudao[]" value="4" /><label>&nbsp; 微博 &nbsp;&nbsp;&nbsp;</label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="add_5" data-margin="55" onclick="intoHTML(this);" style="width: 100px;height: 100px;float: left;margin-top: 55px;background-image: url('__IMG__/addpic.png');background-size: 100px 100px;"></div>
            <div style="clear: both"></div>
            <!--曝光率和到达率的二期新增  end -->
            <div class="item4">
                <div class="item4_left">
                    任务区域
                </div>
                <div class="item4_middle">
                    <div class="select" id="sheng" onclick="selectclick(2);">
                        <div class="option task_sheng">
                            请选择省份
                        </div>
                        <div class="sanjiao_wrap">

                            <img class="sanjiao2" src="__IMG__/select.png" id="sanjiao2">
                        </div>


                    </div>
                    <div class="select" id="shi" onclick="selectclick(3);">
                        <div class="option task_shi">
                            请选择市
                        </div>
                        <div class="sanjiao_wrap">
                            <img class="sanjiao2" src="__IMG__/select.png" id="sanjiao3">
                        </div>
                    </div>
                    <div class="select" id="qu" onclick="selectclick(4);">
                        <div class="option task_qu" style="overflow: hidden;padding-right: 30px">
                            请选择区
                        </div>
                        <div class="sanjiao_wrap">
                            <img class="sanjiao2" src="__IMG__/select.png" id="sanjiao4">
                        </div>
                    </div>
                    <div class="alloption" id="alloption2" style="left:0px">
                        <div class="everyoption" value="-1">
                            全国
                        </div>
                        {volist name='pros' id='p'}
                        <div class="everyoption" value="{$p.district_id}">
                            {$p.district}
                        </div>
                        {/volist}
                    </div>
                    <div class="alloption" id="alloption3" style="left:180px">

                    </div>
                    <div class="alloption" id="alloption4" style="left:360px">

                    </div>

                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    任务总数
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_num" id="task_num" type="text" oninput = "handleMoney(this,0);" placeholder="请输入数字" style="width:160px;">
                    <div class="danwei">/个</div>
                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    单个任务金额
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_price" id="task_price" type="text" oninput = "handleMoney(this,1);" placeholder="最多保留一位小数" style="width:160px;">
                    <div class="danwei">/平台币
                        <span style="margin-left:20px;">任务金额
                   </span>
                    </div>
                    <div class="text">注：1元=10平台币
                    </div>


                </div>
            </div>
            <div class="item4" style="padding-top:15px;">
                <div class="item4_left">
                    任务总金额

                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" type="text" name="money" id="money" value="0" style="width:160px;" readonly>
                    <div class="danwei">/平台币

                    </div>

                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    任务名称

                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" maxlength="25" name="task_name" type="text" placeholder="请输入任务名称">
                </div>
            </div>
            <div class="item4" style="height:auto;">
                <div class="item4_left">
                    任务图片
                </div>
                <input type="file" accept="image/*" id="fileimg" onChange="previewimg(this)" style="display:none;" name ="input_image" >
                <div class="item4_middle"  id="uploader"><!--如果不加这个id=uploader下面的王编辑器加载不出来。。。-->
                    <div class="add uploadimg">
                        <img src="__IMG__/addpic.png" alt="">
                    </div>
                    <div class="add imgshow hidden">
                        <img id="imgsrc" src="" alt="">
                        <div class="delete" onclick="delimg();">
                            删除
                        </div>
                    </div>
                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    起止时间
                </div>
                <div class="item4_middle">
                    <div class="startime">
                        <input style="border: none" type="text" name="task_starttime" class="startime_text test_item" placeholder="请输入开始时间" readonly />
                    </div>
                    <div>至</div>
                    <div class="startime" style="margin-left:10px;">
                        <input style="border: none" type="text" class="startime_text test_item" name="task_endtime" placeholder="请输入结束时间" readonly />
                    </div>
                </div>
            </div>
            <div class="item4" style="height:auto;">
                <div class="item4_left">
                    任务简介

                </div>
                <div id="LAY_editor" style="width:750px;">
                    <p></p>
                </div>
            </div>
            <div class="item4" style="height:auto;">
                <div class="item4_left">

                </div>
                <div style="width: 750px;height: 20px;line-height: 20px;margin-top: -30px;color: gray;font-size: 13px;">
                    注：分享任务内容插入链接需点击编辑器 <img src="__IMG__/href.png" height="17"> 图标进行插入，建议插入链接名称和链接一致
                </div>
            </div>
            <!--d-->
            <div class="aaa_boss">
            <div class="item4 aaa_type">
                <div class="item4_left">
                    分享内容类型
                </div>
                <div class="item4_middle">
                    <div class="lable" onclick="choosetype2(0)">
                        <span class="span11 hidden"></span>
                        <img src="__IMG__/radio.png" class="radioched2"> 编辑器

                    </div>
                    <div class="lable" onclick="choosetype2(1)">
                        <img src="__IMG__/radio.png" class="radioched2 hidden">
                        <span class="span11"></span> 链接
                    </div>
                    <div class="lable" onclick="choosetype2(2)">
                        <img src="__IMG__/radio.png" class="radioched2 hidden">
                        <span class="span11"></span> 图片
                    </div>
                </div>
            </div>
                <div class="item4 sharepic hidden" style="height:auto;">
                    <div class="item4_left">
                        分享的图片
                    </div>
                    <input type="file" accept="image/*" id="fileimg2" onChange="previewimg22(this)" style="display:none;" name ="input_image22" >
                    <div class="item4_middle"  id="uploader2"><!--如果不加这个id=uploader下面的王编辑器加载不出来。。。-->
                        <div class="add uploadimg2">
                            <img src="__IMG__/addpic.png" alt="">
                        </div>
                        <div class="add imgshow2 hidden">
                            <img id="imgsrc2" src="" alt="">
                            <div class="delete" onclick="delimg22();">
                                删除
                            </div>
                        </div>
                    </div>
                </div>
            <div class="item4 aaa_href hidden">
                <div class="item4_left">
                    分享链接
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_share_href" type="text" placeholder="请输入分享链接">
                </div>
            </div>
            <!--d-->
            <div class="item4" style="height:auto;margin-bottom:0;" id="forshare">
                <div class="item4_left">
                    任务内容
                </div>
                <div id="LAY_editor2" style="width:750px;">
                    <p></p>
                </div>
            </div>
            </div>
            <div class="item4" style="height:34px;padding:40px 0;margin-bottom:0;">
                <div class="item4_left">

                </div>
                <div class="item4_middle">
                    <div class="btn1">
                        立即发布

                    </div>
                    <div class="btn2" onclick="history.go(-1)">
                        取消
                    </div>
                </div>
            </div>

        </div>
        <input type="hidden" name="task_type" id="task_type" value="6" />
        <input type="hidden" name="task_active" id="task_active" value="1" />
        <input type="hidden" name="task_share_type" id="task_share_type" value="2" />
        <input type="hidden" name="task_share_content_type" id="task_share_content_type" value="1" />
        <input type="hidden" name="task_sheng" id="task_sheng" value="" />
        <input type="hidden" name="task_shi" id="task_shi" value="" />
        <input type="hidden" name="task_qu" id="task_qu" value="" />
        <input type="hidden" name="task_image" id="task_image" value="" /><!--为1没传图  为2已传图-->
        <input type="hidden" name="task_image2" id="task_image2" value="" /><!--为1没传图  为2已传图-->
        <!--防止重复提交-->
        <input type="hidden" name="repeatSubmit" id="repeatSubmit" value="1" />
        <!--<input type="submit" value="上传文件">-->
    </form>
</div>
</div>
</body>
{include file="public/footer"}
<script type="text/javascript" src="__JSS__/plugins/layui/layui.all.js"></script>
<script type="text/javascript" src="__JS__/wk.js"></script>
<script type="text/javascript" src="__JS__/webuploader/webuploader.js"></script>
<script src="__JSS__/plugins/wangEditor-3.1.1/release/wangEditor.js" ></script>
<script src="__SCRIPT__/common.js" ></script>
<script>
//    var n = wk.uploads({num:3,type:'jpg,jpeg,png',url:"{:url('shop/upload/uploadLocality')}"});
//    function imgDel(e,obj){
//        wk.uploads_del(e,obj,n,"{:url('shop/upload/deleteLocality')}");
//    }
layui.use('laydate', function () {
    var laydate = layui.laydate;
    //同时绑定多个
    lay('.test_item').each(function(){
        laydate.render({
            elem: this
            ,format:'yyyy-MM-dd HH:mm'
            ,type:'datetime'
            ,trigger: 'click'
        });
    });
    });


    var editor = wk.wang({elem:'#LAY_editor',url:"{:url('shop/upload/wangUpload')}"});
    var editor2 = wk.wang({elem:'#LAY_editor2',url:"{:url('shop/upload/wangUpload')}"});
</script>
<script type="text/javascript">
    //普通/活动任务选择
    $('#alloption7 .everyoption').click(function () {
        var val = $(this).attr('value');
        var text = $(this).text();
        $('#task_active').val(val);
        $('.task_active').text(text);
        selectclick(7);
    });
    function selectclick(index) {
        // alert(1);
        if (document.getElementById('alloption' + index).style.display != 'block') {
            document.getElementById('alloption' + index).style.display = 'block';
            document.getElementById('sanjiao' + index).className = 'sanjiao1';
        } else {
            document.getElementById('sanjiao' + index).className = 'sanjiao2';
            document.getElementById('alloption' + index).style.display = 'none';
        }
        if(index == 1 && document.getElementById('alloption' + 7).style.display == 'block'){
            selectclick(7);
        }
    }
    function choosetype2(index) {
//
        if(index == 0){
            $('#forshare').removeClass('hidden');
            $('.aaa_href').addClass('hidden');
            $('.sharepic').addClass('hidden');
        }else if(index == 1){
            $('.aaa_href').removeClass('hidden');
            $('#forshare').addClass('hidden');
            $('.sharepic').addClass('hidden');
        }else{
            $('.aaa_href').addClass('hidden');
            $('#forshare').addClass('hidden');
            $('.sharepic').removeClass('hidden');

        }
//
        var span1 = document.getElementsByClassName('span11');
        var radioched = document.getElementsByClassName('radioched2');
        for (var i = 0; i < span1.length; i++) {
            span1[i].className = 'span11';
            radioched[i].className = 'radioched2 hidden';

        }
        span1[index].className = 'span11 hidden';
        radioched[index].className = 'radioched2';
        $('#task_share_content_type').val(index+1);
    }
    $('.uploadimg').click(function () {
        $('#fileimg').click();
    });
    $('.uploadimg2').click(function () {
        $('#fileimg2').click();
    });
    function previewimg(obj){
        var src = window.URL.createObjectURL(obj.files[0]);
        $('#imgsrc').attr('src',src);
        $('.imgshow').removeClass('hidden');
        uploadImageCommon('fabutask','task_image',0);
    }
    function previewimg22(obj){
        var src = window.URL.createObjectURL(obj.files[0]);
        $('#imgsrc2').attr('src',src);
        $('.imgshow2').removeClass('hidden');
        uploadImageCommon('fabutask','task_image2',1);
    }
    function delimg(){
        $('.imgshow').addClass('hidden');
        $('#task_image').val('');
    }
    function delimg22(){
        $('.imgshow2').addClass('hidden');
        $('#task_image2').val('');
    }
    $('.btn1').click(function () {
//        var formData = new FormData($( "#fabutask" )[0]);//addForm是表单的id，不是input file的
//        formData.append("task_content", editor.txt.html());
//        formData.append("task_share_content", editor2.txt.html());
        var repeatSubmit = $('#repeatSubmit').val();
        if(repeatSubmit == 2){
            alert('请勿重复提交！');
            return false;
        }else{
            var submitInfo = formCheck();
            if(submitInfo.status == 200){
//
                var up_task_fen = '';
                for(var indexx in form_data) {
                    up_task_fen += form_data[indexx] + '|';
                }
//
                $('#repeatSubmit').val(2);
                var formData = $( "#fabutask" ).serialize();
                var task_content = editor.txt.html();
                var task_share_content = editor2.txt.html();
                formData += '&task_content='+task_content+'&task_share_content='+task_share_content+'&up_task_fen='+up_task_fen;
                $.ajax({
                    url: '/shop/Task/releaseTask',
                    data: formData,
                    type: 'POST',
                    dataType: 'JSON',
                    success: function (returnData) {
                        alert(returnData.msg);
                        if(returnData.status == 200){
                            window.location.href = '/shop/Task/homePage';
                            return true;
                        }else{
                            $('#repeatSubmit').val(1);
                        }
                    },
                    error: function () {
                        alert('服务器错误，请刷新重试！');
                    }
                })
            }else{
                alert(submitInfo.msg);
                return false;
            }
        }
    });

</script>
<script>
    //***************************省市区的选择**************************
    /**
     * 点击省
     */
    $('#alloption2 .everyoption').click(function () {
        var val = $(this).attr('value');
        var text = $(this).text();
        $('#task_sheng').val(val);
        $('.task_sheng').text(text);
        allAreaNone(1);
        $('#alloption3,#alloption4').empty();
        if(val != -1){
            $.ajax({
                url: '/shop/Task/getAreaByType',
                data: 'type=2&id='+val,
                type: 'POST',
                dataType: 'JSON',
                success: function (returnData) {
                    $("#alloption3").append('<div class="everyoption" value="-1">全部</div>');
                    var datas = returnData.msg;
                    $.each(datas,function(key,v){
                        $("#alloption3").append('<div class="everyoption" value="'+v.district_id+'">'+v.district+'</div>');
                    });
                    /**
                     * 点击市
                     */
                    $('#alloption3 .everyoption').click(function () {
                        var val = $(this).attr('value');
                        var text = $(this).text();
                        $('#task_shi').val(val);
                        $('.task_shi').text(text);
                        allAreaNone(2);
                        $('#alloption4').empty();
                        if(val != -1){
                            $.ajax({
                                url: '/shop/Task/getAreaByType',
                                data: 'type=3&id='+val,
                                type: 'POST',
                                dataType: 'JSON',
                                success: function (returnData) {
                                    $("#alloption4").append('<div class="everyoption" value="-1">全部</div>');
                                    var datas = returnData.msg;
                                    $.each(datas,function(key,v){
                                        $("#alloption4").append('<div class="everyoption" value="'+v.district_id+'">'+v.district+'</div>');
                                    });
                                    $("#alloption4").append('<div class="everyoption" style="text-align: center;" value="999999">确定</div>');
                                    /**
                                     * 点击区
                                     */
                                    $('#alloption4 .everyoption').click(function () {
                                        var val = $(this).attr('value');
                                        var text = $(this).text();
                                        if(val == -1){
                                            $('#task_qu').val(val);
                                            $('.task_qu').text(text);
                                            allAreaNone(3);
                                            $('#alloption4 .everyoption').removeClass('selecttttName1');
                                        }else if(val == 999999){
                                            allAreaNone(3);
                                        }else{
                                            $('#alloption4 .everyoption').eq(0).removeClass('selecttttName1');
                                            if($(this).hasClass('selecttttName1')){
                                                $(this).removeClass('selecttttName1');
                                            }else{
                                                $(this).addClass('selecttttName1');
                                            }
                                            var qu_ids = '';
                                            var qu_str = '';
                                            $('#alloption4 .everyoption').each(function (i,d) {
                                                if($(d).hasClass('selecttttName1')){
                                                    qu_ids += $(d).attr('value')+',';
                                                    qu_str += $(d).text()+' ';
                                                }
                                            });
                                            $('#task_qu').val(qu_ids);
                                            $('.task_qu').text(qu_str);
                                        }
                                    });
                                },
                                error: function () {
                                    alert('ajax error，请刷新重试');
                                }
                            })
                        }
                    });
                },
                error: function () {
                    alert('ajax error，请刷新重试');
                }
            })
        }
    });

    function allAreaNone(type) {
        document.getElementById('sanjiao2').className = 'sanjiao2';
        document.getElementById('alloption2').style.display = 'none';
        document.getElementById('sanjiao3').className = 'sanjiao2';
        document.getElementById('alloption3').style.display = 'none';
        document.getElementById('sanjiao4').className = 'sanjiao2';
        document.getElementById('alloption4').style.display = 'none';
        if(type == 1){
            $('#task_shi').val('');
            $('.task_shi').text('请选择市');
            $('#task_qu').val('');
            $('.task_qu').text('请选择区');
        }
        if(type == 2){
            $('#task_qu').val('');
            $('.task_qu').text('请选择区');
        }
    }
</script>
<script>
    function handleMoney(obj,type){
        if(type == 0){
            obj.value = obj.value.replace(/[^\d]/g, '');
            obj.value = obj.value.replace(/\.{2,}/g, '.');
            obj.value = obj.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
            if (obj.value.indexOf('.') < 0 && obj.value != '') {
                obj.value = parseFloat(obj.value);
            }
            if ((obj.value.length == 1 && obj.value == '.') || obj.value.substring(0,1) == '.') {
                obj.value = '';
            }
        }else{
            obj.value = obj.value.replace(/[^\d.]/g, '');
            obj.value = obj.value.replace(/\.{2,}/g, '.');
            obj.value = obj.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
//            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d).*$/, '$1$2.$3'); //只能输入1个小数
            if (obj.value.indexOf('.') < 0 && obj.value != '') {
                obj.value = parseFloat(obj.value);
            }
            if ((obj.value.length == 1 && obj.value == '.') || obj.value.substring(0,1) == '.') {
                obj.value = '';
            }
        }

        var value1 = $('#task_num').val();
        var value2 = $('#task_price').val();
        if(value1 && value2){
            var res = value1*value2;
            $('#money').val(res.toFixed(1));
        }else{
            $('#money').val(0);
        }
    }
</script>
<script>
    function formCheck() {
        var befroe = add5status();
        if(befroe.status != 200){
            return befroe;
        }else {
            var res = {
                'status': '200',
                'msg': 'OK'
            };
            var task_share_timeout = $('input[name="task_share_timeout"]').val();

            var task_type = $('input[name="task_type"]').val();
            var task_href = $('input[name="task_href"]').val();
            var task_num = $('input[name="task_num"]').val();
            var task_price = $('input[name="task_price"]').val();
            var task_sheng = $('input[name="task_sheng"]').val();
            var task_shi = $('input[name="task_shi"]').val();
            var task_qu = $('input[name="task_qu"]').val();
            var money = $('input[name="money"]').val();
            var task_image = $('input[name="task_image"]').val();
            //分享图片
            var task_image2 = $('input[name="task_image2"]').val();
            //
            var task_name = $('input[name="task_name"]').val();
            var task_starttime = $('input[name="task_starttime"]').val();
            var task_endtime = $('input[name="task_endtime"]').val();
            var task_content = editor.txt.html();
            var task_share_content = editor2.txt.html();

            if (!task_share_timeout || task_share_timeout <= 0) {
                res.status = 0;
                res.msg = '每步完成时间不能为空';
                return res;
            }
            if (task_type == 6) {
                var task_share_content_type = $('input[name="task_share_content_type"]').val();
                var task_share_href = $('input[name="task_share_href"]').val().trim();
                if (task_share_content_type == 1) {
                    if (task_share_content == '<p><br></p>' || task_share_content == '<p></p><p><br></p>') {
                        res.status = 0;
                        res.msg = '分享任务的内容不能为空';
                        return res;
                    }
                } else if(task_share_content_type == 2){
                    if (task_share_href == '') {
                        res.status = 0;
                        res.msg = '分享任务的分享链接不能为空';
                        return res;
                    }
                }else{
                    if(!task_image2){
                        res.status = 0;
                        res.msg = '分享任务的分享图片不能为空';
                        return res;
                    }
                }
                //分享渠道 TODO
                var qudao = $('input[name="tf_qudao[]"]:checked').val();
                if (qudao == 'undefined' || !qudao) {
                    res.status = 0;
                    res.msg = '分享任务的分享渠道不能为空';
                    return res;
                }
            }
            if (!task_sheng) {
                res.status = 0;
                res.msg = '请选择任务区域';
                return res;
            } else {
                if (task_sheng != -1) {
                    if (!task_shi) {
                        res.status = 0;
                        res.msg = '请选择任务所在市';
                        return res;
                    } else {
                        if (task_shi != -1) {
                            if (!task_qu) {
                                res.status = 0;
                                res.msg = '请选择任务所在区';
                                return res;
                            }
                        }

                    }
                }
            }
            if (!task_num) {
                res.status = 0;
                res.msg = '任务总数不能为空';
                return res;
            }
            if (!task_price) {
                res.status = 0;
                res.msg = '任务单个金额不能为空';
                return res;
            }
            if (!task_name) {
                res.status = 0;
                res.msg = '任务名称不能为空';
                return res;
            }
            if (!task_image) {
                res.status = 0;
                res.msg = '任务图片不能为空';
                return res;
            }
            if (!task_starttime || !task_endtime) {
                res.status = 0;
                res.msg = '任务开始时间或结束时间不能为空';
                return res;
            } else {
                var today = Date.parse(new Date()) / 1000;
                var begin = datetime_to_unix(task_starttime + ':00');
                var end = datetime_to_unix(task_endtime + ':00');
                if (begin <= today) {
                    res.status = 0;
                    res.msg = '任务开始时间不能小于当前时间';
                    return res;
                }
                var cb = (end - begin) / 3600;
                if (cb < 48) {
                    res.status = 0;
                    res.msg = '任务开始时间不能大于结束时间且相隔不能低于48小时';
                    return res;
                }
            }
            if (task_content == '<p><br></p>' || task_content == '<p></p><p><br></p>') {
                res.status = 0;
                res.msg = '任务简介不能为空';
                return res;
            }
            return res;
        }
    }
    function datetime_to_unix(datetime){
        var tmp_datetime = datetime.replace(/:/g,'-');
        tmp_datetime = tmp_datetime.replace(/ /g,'-');
        var arr = tmp_datetime.split("-");
        var now = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5]));
        return parseInt(now.getTime()/1000);
    }
</script>
<script>
    var form_data = new Array();
    var _html = $('.erqifen').html();
    function intoHTML(el) {
        //0、先判断当前填写是否正确
        var res = add5status();
        if(res.status != 200){
            alert(res.msg);
            return false;
        }else{
            //1、先高度
            var margin = $(el).attr('data-margin');
            $(el).attr('data-margin',margin-0+210);
            $(el).css('margin-top',margin-0+210+'px');
            //2、获取最新的一步的id
            var ji = $('.five').length;
            var now = $('.five')[ji-1].id;
            var arr = now.split('_');
            //3、把删除按钮漏出来
            $('#'+now+' .five_'+arr[1]).css('display','block');
            //4、填完的不能改了
            $('.five input[name="tf_submit"]:checked').siblings('span').css('color','blue');
            $('.five input[name="tf_submit"]').css('display','none');
            $('.five input').prop('disabled',true);
            //5、塞HTML
            $('.erqifen').append(_html);
            //6、改最新的div的id
            var ji = $('.five').length;
            $('.five')[ji-1].id = 'five_'+(arr[1]-0+1);
            //7、把删除按钮的class调整到和div的id一致
            $('#'+'five_'+(arr[1]-0+1)+' .five_1').addClass('five_'+(arr[1]-0+1));
            $('#'+'five_'+(arr[1]-0+1)+' .five_1').removeClass('five_1');
            if($('.five').length >= 5){
                $('.add_5').addClass('hidden');
            }else{
                $('.add_5').removeClass('hidden');
            }
            gaizi();
        }

    }
    function add5status() {
        var res = {
            'status':'200',
            'msg':'OK'
        };
        var ji = $('.five').length;
        var now = $('.five')[ji-1].id;

        var tf_desc = $('#'+now+' input[name="tf_desc"]').val().trim();
        var tf_submit = $('#'+now+' input[name="tf_submit"]:checked').val();
        var tf_money = $('#'+now+' input[name="tf_money"]').val();
        var tf_qudao = '';
        $('#'+now+' input[name="tf_qudao[]"]:checked').each(function (i,d) {
            tf_qudao += d.value+',';
        });
        if(tf_desc == ''){
            res.status = 0;
            res.msg = '描述不能为空';
            return res;
        }
        if(tf_money == '' || tf_money <= 0){
            res.status = 0;
            res.msg = '任务金额不能为空';
            return res;
        }
        if(tf_qudao == ''){
            res.status = 0;
            res.msg = '分享渠道不能为空';
            return res;
        }
        tf_qudao = tf_qudao.substring(0,tf_qudao.length-1);
        form_data[now] = tf_desc + '_' + tf_submit + '_' + tf_money + '_' + tf_qudao;
        return res;
    }
    function shanchu(el) {
        var nowid = $(el).attr('class');
        var arr = form_data;
        for(var index in arr) {
            form_data = new Array();
            if(index != nowid){
                form_data[index] = arr[index];
            }
        }
        $('#'+nowid).remove();
        //调整高度
        var margin = $('.add_5').attr('data-margin');
        $('.add_5').attr('data-margin',margin-210);
        $('.add_5').css('margin-top',margin-210+'px');
        if($('.five').length >= 5){
            $('.add_5').addClass('hidden');
        }else{
            $('.add_5').removeClass('hidden');
        }
        gaizi();
    }
    function gaizi() {
        //--改字
        $('.five').each(function (iii,ddd) {
            var iiiddd = $(ddd).attr('id');
            $('#'+iiiddd+' .item4_left').eq(0).text('第 '+(iii-0+1)+' 步描述');
        });
        //--改字
    }
</script>